<template>
  <a-card :bordered="false">
    <div style="margin-left: 15px;  color: orange">
      {{ $t('说明：如下数据项开启后在免责签署过程中将为必填项，不填会有提醒并禁止后面的操作') }}
    </div>
    <div style="margin-left: 15px; margin-top: 15px; display: flex; padding: 14px 0">
      <div style="font-weight: bold; color: #000">{{ $t('基本信息') }}</div>
    </div>
    <div style="margin-left: 15px; margin-top: 10px; display: flex; gap: 10px;">
      <a-checkbox :checked="model.firstName == 1" @change="(e) => changeRequired(e, 'firstName')">
        {{ $t('名称') }}
      </a-checkbox>
      <a-checkbox :checked="model.lastName == 1" @change="(e) => changeRequired(e, 'lastName')"
        style="margin-left: 20px;">
        {{ $t('姓氏') }}
      </a-checkbox>
      <a-checkbox :checked="model.birthday == 1" @change="(e) => changeRequired(e, 'birthday')"
        style="margin-left: 20px;">
        {{ $t('生日') }}
      </a-checkbox>
      <a-checkbox :checked="model.gender == 1" @change="(e) => changeRequired(e, 'gender')" style="margin-left: 20px;">
        {{ $t('性别') }}
      </a-checkbox>
      <a-checkbox :checked="model.phone == 1" @change="(e) => changeRequired(e, 'phone')" style="margin-left: 20px;">
        {{ $t('电话') }}
      </a-checkbox>
      <a-checkbox :checked="model.email == 1" @change="(e) => changeRequired(e, 'email')" style="margin-left: 20px;">
        {{ $t('邮箱') }}
      </a-checkbox>
    </div>
    <div style="margin-left: 15px; margin-top: 15px; display: flex; padding: 14px 0">
      <div style="font-weight: bold; color: #000">{{ $t('地区信息') }}</div>
    </div>
    <div style="margin-left: 15px; margin-top: 10px; display: flex; gap: 10px;">
      <a-checkbox :checked="model.country == 1" @change="(e) => changeRequired(e, 'country')">
        {{ $t('国家') }}
      </a-checkbox>
      <a-checkbox :checked="model.address1 == 1" @change="(e) => changeRequired(e, 'address1')"
        style="margin-left: 20px;">
        {{ $t('地址1') }}
      </a-checkbox>
      <a-checkbox :checked="model.address2 == 1" @change="(e) => changeRequired(e, 'address2')"
        style="margin-left: 20px;">
        {{ $t('地址2') }}
      </a-checkbox>
      <a-checkbox :checked="model.city == 1" @change="(e) => changeRequired(e, 'city')" style="margin-left: 20px;">
        {{ $t('城市') }}
      </a-checkbox>
      <a-checkbox :checked="model.province == 1" @change="(e) => changeRequired(e, 'province')"
        style="margin-left: 20px;">
        {{ $t('州/省') }}
      </a-checkbox>
      <a-checkbox :checked="model.postalCode == 1" @change="(e) => changeRequired(e, 'postalCode')"
        style="margin-left: 20px;">
        {{ $t('邮编') }}
      </a-checkbox>
    </div>
    <div style="margin-left: 15px; margin-top: 15px; display: flex; padding: 14px 0">
      <div style="font-weight: bold; color: #000">{{ $t('照片信息') }}</div>
    </div>
    <div style="margin-left: 15px; margin-top: 10px; display: flex; gap: 10px;">
      <a-checkbox :checked="model.takePicture == 1" @change="(e) => changeRequired(e, 'takePicture')">
        {{ $t('拍照') }}
      </a-checkbox>
    </div>
    <div style="margin-left: 15px; margin-top: 15px; display: flex; padding: 14px 0">
      <div style="font-weight: bold; color: #000">{{ $t('孩子信息') }}</div>
    </div>
    <div style="margin-left: 15px; margin-top: 10px; display: flex; gap: 10px;">
      <a-checkbox :checked="model.oneChild == 1" @change="(e) => changeRequired(e, 'oneChild')">
        {{ $t('至少填一个孩子信息') }}
      </a-checkbox>
    </div>
    <div style="margin-left: 15px; margin-top: 15px; display: flex; gap: 10px;">
      <a-checkbox :checked="model.childFirstName == 1" @change="(e) => changeRequired(e, 'childFirstName')">
        {{ $t('孩子名称') }}
      </a-checkbox>
      <a-checkbox :checked="model.childLastName == 1" @change="(e) => changeRequired(e, 'childLastName')"
        style="margin-left: 20px;">
        {{ $t('孩子姓氏') }}
      </a-checkbox>
      <a-checkbox :checked="model.childBirthday == 1" @change="(e) => changeRequired(e, 'childBirthday')"
        style="margin-left: 20px;">
        {{ $t('孩子生日') }}
      </a-checkbox>
      <a-checkbox :checked="model.childGender == 1" @change="(e) => changeRequired(e, 'childGender')"
        style="margin-left: 20px;">
        {{ $t('孩子性别') }}
      </a-checkbox>
      <a-checkbox :checked="model.relationship == 1" @change="(e) => changeRequired(e, 'relationship')"
        style="margin-left: 20px;">
        {{ $t('关系') }}
      </a-checkbox>
    </div>
  </a-card>
</template>

<script>
import { getAction, httpAction } from '@/api/manage';

export default {
  name: 'BisLiabilityRequired',
  components: {
  },
  data() {
    return {
      description: '管理设置',
      model: {},
      url: {
        list: '/game/bisLiabilityRequired/list',
        add: '/game/bisLiabilityRequired/add',
        edit: '/game/bisLiabilityRequired/edit',
      },
    }
  },
  created() {
    this.getRequired();
  },
  methods: {
    getRequired() {
      getAction(this.url.list).then((res) => {
        if (res.success) {
          if (res.result.records.length > 0) {
            this.model = res.result.records[0]
          }
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    changeRequired(e, key) {
      this.$set(this["model"], key, e.target.checked ? 1 : 0)
      let url = ''
      let method = ''
      if (this.model.id) {
        url = this.url.edit
        method = 'put'
      } else {
        url = this.url.add
        method = 'post'
      }
      httpAction(url, this.model, method).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.getRequired()
        } else {
          this.$message.warning(res.message)
        }
      })
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>